﻿namespace FiftyOne.Foundation.Mobile.Detection.Wurfl.Handlers
{
    using System;

    internal class BoltHandler : SafariHandler
    {
        private const string DEFAULT_DEVICE = "generic_bolt_ver1";
        private const byte EXTRA_CONFIDENCE = 1;
        private static readonly string[] PATTERNS = new string[] { @"(?<=Mozilla/\d.\d \()[^)]+", @"(?<=AppleWebKit/)[\d.]+", @"(?<=Version/)[\d.]+", @"(?<=Safari/)[\d.]+", @"(?i)(?<=bolt/)[\d.]+" };
        private static readonly string[] SUPPORTED_ROOT_DEVICES = new string[] { "generic_bolt_ver1" };

        public BoltHandler() : base(PATTERNS, new int[] { 3, 1, 1, 1, 1 })
        {
        }

        protected internal override bool CanHandle(string userAgent)
        {
            return (base.CanHandle(userAgent) && (userAgent.IndexOf("bolt", StringComparison.InvariantCultureIgnoreCase) >= 0));
        }

        internal override byte Confidence
        {
            get
            {
                return (byte) (base.Confidence + 1);
            }
        }

        protected override string[] SupportedRootDeviceIds
        {
            get
            {
                return SUPPORTED_ROOT_DEVICES;
            }
        }
    }
}

